<template>
	<view class="content">
		<view class="section section-1">
			<view class="section-body">
				<view class="tab">
					<view  @click="setCurIdx(idx, item.id, item.name)" :class="`item ${curIdx === idx ? 'item__active' : ''} ${curIdx + 1 === idx ? 'item__active_next' : ''}`" v-for="(item, idx) in tabList" :key="item.id">
						<view class="label">{{item.name}}</view>
						<view class="shape">
							<view class="shape-body"></view>
						</view>
						<view class="shape shape-mirrow">
							<view class="shape-body"></view>
						</view>
					</view>
				</view>
				<view v-if="curIdx != 2">
					<view class="info" v-for="(item,index) in listData" :key="index">
						<view class="top-title">
							<view class="company">
								{{item.name}}
							</view>
						</view>
						<view class="wrapper" v-for="(item2,index) in item.list" :key="index">
							<view class="title">{{item2.position}}</view>
							<view class="value">
								<view class="member" v-for="(item3,index) in item2.children" :key="index">
									<text class="name">
										{{item3.zrr_name}} 
										<text @click="handleCall(item3.zrr_tel)" class="tel">
											<text class="iconfont icon-24gl-phoneLoudspeaker"></text>
											{{item3.zrr_tel}}
										</text>
									</text>
									<view class="evaluate">
										<view class="rate">
											{{item3.score}}分
										</view>
										<text class="evaluate-btn" @click="goComment(item3.id)">评价</text>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
				<view v-else>
					<view class="info-sg">
						<view class="wrapper-sg" v-for="(item,index) in listData2" :key="index">
							<view class="unit">
								<view class="unit-title">
									{{item.name}}
								</view>
								<text class="unit-show" @click="queryFun(item.id)">查看人员<text class="iconfont icon-xiangyou1"></text></text>
							</view>
							<view class="value-sg" v-for="(item2,index) in item.children" :key="index">
								<view class="title-sg" >
									{{item2.type}}									
								</view>
								<view class="member-sg" v-for="(item3,index) in item2.list" :key="index">
									<text class="name-sg">{{item3.name}}</text>
									<view class="evaluate-sg">
										<text @click="queryFun(item3.id)">查看人员<text class="iconfont icon-xiangyou1"></text></text>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { companyListApi } from '@/api/person.js';
	import { mapGetters, mapActions} from 'vuex';
	export default {
		data() {
			return {
				count: 5,
				value: 1,
				tabList: [
					{ id: 1, name: '业主单位'},
					{ id: 2, name: '监理单位'},
					{ id: 3, name: '施工单位'},
					{ id: 4, name: '设计单位'},
				],
				curIdx: 0,
				curId: 1,
				curName: '业主单位',
				listData: [],
				listData2: [],
			}
		},
		computed: {
			...mapGetters({
				curProject: 'system/getCurProject',
			})
		},
		methods: {
			queryFun(v) {
				uni.navigateTo({
					url: "/pages/work/manager/construction/safety/person/query/query?id=" + v
				})
			},
			async companyList() {
				let j = await companyListApi({
					project_id: this.curProject.id,
					type: this.curName
				})
				let result = j.data.data;
				if(result[0].type == "自有单位") {
					this.listData2 = result;
				}else{
					this.listData = j.data.data[0];
				}
			},
			goComment(commentId) {
				uni.navigateTo({
					url: "/pages/work/manager/construction/safety/person/evaluate/evaluate?commentId=" + commentId
				})
			},
			handleCall(number) {
				uni.makePhoneCall({
				    phoneNumber: number
				});
			},
			setCurIdx(idx, id, name) {
				this.curIdx = idx;
				this.curId = id;
				this.curName = name
				this.companyList()
			},
		},
		onLoad(data) {
			this.companyList()
		}
	}
</script>

<style lang="scss" scoped>
	page{
		background-color: #fff;
	}
	.section-1{
		width: 100%;
		background-color: #3759f2;
		.section-body{
			width: 100%;
			border-top-left-radius: 40rpx;
			border-top-right-radius: 40rpx;
			background-color: #fff;
			overflow: hidden;
			.tab{
				width: 100%;
				height: 80rpx;
				@include clear();
				background-color: #1534ce;
				.item{
					width: 25%;
					float: left;
					height: 80rpx;
					background-color: #1534ce;
					position: relative;
					.label{
						height: 80rpx;
						line-height: 80rpx;
						position: relative;
						z-index: 10;
						box-sizing: border-box;
						text-align: center;
						width: 100%;
						font-size: 26rpx;
						font-weight: normal;
						font-stretch: normal;
						letter-spacing: 0rpx;
						color: #ffffff;
					}
					.shape{
						z-index: 1;
						width: 50rpx;
						height: 50rpx;
						position: absolute;
						bottom: 0;
						left: -50rpx;
						background: #000;
						display: none;
						background-color: #fff;
						overflow: hidden;
						.shape-body{
							width: 50rpx;
							height: 50rpx;
							background-color: #1534ce;
							border-bottom-right-radius: 40rpx;
						}
					}
					.shape-mirrow{
						z-index: 1;
						left: 0;
						display: none;
						.shape-body{
							border-bottom-right-radius: 0rpx;
							border-bottom-left-radius: 40rpx;
						}
					}
				}
				.item__active{
					border-top-left-radius: 40rpx;
					border-top-right-radius: 40rpx;
					background-color: #fff;
					.label{
						color: #46464a;
					}
					.shape{
						display: block;
					}
					.shape-mirrow{
						display: none;
					}
				}
				.item__active_next{
					border-bottom-right-radius: 50rpx;
					.shape{
						display: none;
					}
					.shape-mirrow{
						display: block;
					}
				}
				
			}
		}
		.info{
			width: 100%;
			background-color: #fff;
			box-sizing: border-box;
			padding: 0 40rpx;
			.top-title{
				width: 100%;
				padding-bottom: 30rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				.company{
					text-align: left;
					width: 600rpx;
					font-size: 26rpx;
					line-height: 25rpx;
					font-weight: bold;
					font-stretch: normal;
					letter-spacing: 2rpx;
					color: #3b3c40;	
					margin-right: 30rpx;
				}
				.add-btn{
					text-align: center;
					width: 189rpx;
					height: 48rpx;
					border-radius: 21rpx;
					border: solid 2rpx #1534ce;
					font-size: 26rpx;
					font-weight: normal;
					font-stretch: normal;
					line-height: 48rpx;
					letter-spacing: 0rpx;
					color: #1534ce;
				}
			}
			.wrapper{
				width: 100%;
				border-radius: 35rpx;
				background-size: cover;
				background-repeat: no-repeat;
				overflow: hidden;
				box-sizing: border-box;
				box-shadow: 0 0 20rpx 10rpx rgba(#bcbcb5, 0.17);
				padding: 28rpx 40rpx;
				margin-bottom: 24rpx;
				.title {
					width: 100%;
					height: 30rpx;
					line-height: 30rpx;
					border-bottom: solid 3rpx #f2f2f0;
					font-size: 26rpx;
					font-stretch: normal;
					letter-spacing: 0rpx;
					color: #3b3c40;
					padding-bottom: 28rpx;
					view {
						float: right;
						font-size: 26rpx;
						color: #8497ac;
						font-weight: normal;
						.iconfont{
							font-size: 26rpx;
							margin-right: 5rpx;
						}
					}
				}
			
				.value {
					width: 100%;
					padding-top: 28rpx;
					.member{
						width: 100%;
						height: 40rpx;
						line-height: 40rpx;
						margin-bottom: 15rpx;
						&:last-child{
							margin-bottom: 0;
						}
						.name{
							font-size: 26rpx;
							color: #3b3c40;
							margin-right: 10rpx;
							.tel{
								margin-left: 10rpx;
								color: #1d3bd0;
								.icon-24gl-phoneLoudspeaker{
									color: #1d3bd0;
									font-size: 26rpx;
									margin-right: 5rpx;
								}
							}
						}
						.evaluate{
							float: right;
							.rate{
								display: inline-block;
								margin-right: 20rpx;
								font-size: 26rpx;
							}
							.evaluate-btn{
								width: 150rpx;
								font-size: 24rpx;
								padding: 2rpx 15rpx;
								border-radius: 20rpx;
								border: 1px solid #1d3bd0;
								color: #1d3bd0;
								font-weight: bold;
							}
						}
						.icon-bianji1{
							// float: right;
							color: #1d3bd0;
							font-size: 26rpx;
						}
					}
					.record{
						width: 100%;
						@include clear();
						margin-bottom: 25rpx;
						.left{
							width: 100%;
							float: left;
							font-size: 26rpx;
							line-height: 36rpx;
							color: #3b3c40;
							margin-bottom: 10rpx;
						}
						
						.log{
							width: 100%;
							line-height: 28rpx;
							font-size: 20rpx;
							color: #3b3c40;
						}
						&:last-child{
							margin-bottom: 0;
						}
					}
				}
				
			}
		}
		.info-sg{
			width: 100%;
			background-color: #fff;
			box-sizing: border-box;
			padding: 0 40rpx;
			margin-top: 30rpx;
			.top-title{
				width: 100%;
				margin-top: 12rpx;
				padding-bottom: 30rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				.company{
					text-align: left;
					width: 600rpx;
					font-size: 26rpx;
					line-height: 25rpx;
					font-weight: bold;
					font-stretch: normal;
					letter-spacing: 2rpx;
					color: #3b3c40;	
					margin-right: 30rpx;
				}
				
			}
			.wrapper-sg{
				width: 100%;
				border-radius: 35rpx;
				background-size: cover;
				background-repeat: no-repeat;
				overflow: hidden;
				box-sizing: border-box;
				box-shadow: 0 0 20rpx 10rpx rgba(#bcbcb5, 0.17);
				padding: 28rpx 40rpx;
				margin-bottom: 24rpx;
				.unit{
					display: flex;
					flex-direction: row;
					justify-content: flex-start;
					flex-wrap: wrap;
					font-size: 26rpx;
					border-bottom: solid 3rpx #f2f2f0;
					font-stretch: normal;
					letter-spacing: 0rpx;
					color: #3b3c40;
					padding-bottom: 20rpx;
					.unit-title{
						flex: 2;
						font-weight: bold;
					}
					.unit-show{
						display: flex;
						flex-direction: row;
						justify-content: flex-end;
						flex: 1;
						color: #1534ce;
						margin-top: 8rpx;
					}
				}
				.title-sg {
					width: 100%;
					height: 25rpx;
					line-height: 25rpx;
					border-bottom: solid 3rpx #f2f2f0;
					font-size: 26rpx;
					font-stretch: normal;
					letter-spacing: 0rpx;
					color: #3b3c40;
					padding-bottom: 15rpx;
					font-weight: bold;
					.add-btn{
						float: right;
						text-align: center;
						width: 180rpx;
						height: 32rpx;
						border-radius: 21rpx;
						border: solid 2rpx #1534ce;
						font-size: 26rpx;
						font-weight: normal;
						font-stretch: normal;
						line-height: 30rpx;
						letter-spacing: 0rpx;
						color: #1534ce;
						padding: 2rpx 0;
					}
				}
			
				.value-sg {
					width: 100%;
					padding-top: 28rpx;
					.member-sg{
						display: flex;
						flex-direction: row;
						justify-content: flex-start;
						width: 100%;
						height: 50rpx;
						padding-top: 10rpx;
						line-height: 40rpx;
						margin-bottom: 15rpx;
						border-bottom: solid 3rpx #f2f2f0;
						&:last-child{
							margin-bottom: 0;
						}
						.name-sg{
							flex: 2;
							font-size: 26rpx;
							color: #3b3c40;
							margin-right: 13rpx;
							.tel{
								margin-left: 10rpx;
								color: #1d3bd0;
								.icon-24gl-phoneLoudspeaker{
									color: #1d3bd0;
									font-size: 26rpx;
									margin-right: 5rpx;
								}
							}
						}
						.evaluate-sg{
							display: flex;
							flex-direction: row;
							justify-content: flex-end;
							flex: 1;
							font-size: 26rpx;
							color: #1d3bd0;
						}
						.icon-bianji1{
							color: #1d3bd0;
							font-size: 28rpx;
							margin-right: 10rpx;
						}
						.icon-shanchu{
							color: red;
							font-size: 28rpx;
						}
					}
					.certificate{
						font-size: 26rpx;
					}
				}
				
			}
		}
	}
</style>
